<template>
    <el-date-picker v-model="value1" :type="type" :placeholder=placeholder :value-format="valueFormat" @change="emits('search', value1)" :disabled-date="disabledDate"/>
</template>
<script setup>
import { ref, watch } from 'vue'
const value1 = ref()
const emits = defineEmits(['search','update:modelValue',])

defineProps({
    placeholder: {
        type: String,
        default: '请选择时间'
    },
    type: {
        type: String,
        default: 'date'
    },
    valueFormat:{
        type: String,
        default: 'YYYY-MM-DD'
    }
})
watch(value1, (val) => {
    emits('update:modelValue', val)
})


/**
 * 禁用日期
 * @param {*} time 当前时间
 */
 const disabledDate = (time) => {
  const endDate = new Date();
  return  time > endDate;
}
</script>
<style scoped>
.demo-datetime-picker {
    display: flex;
    width: 100%;
    padding: 0;
    flex-wrap: wrap;
}

.demo-datetime-picker .block {
    padding: 30px 0;
    text-align: center;
    border-right: solid 1px var(--el-border-color);
    flex: 1;
}

.demo-datetime-picker .block:last-child {
    border-right: none;
}

.demo-datetime-picker .demonstration {
    display: block;
    color: var(--el-text-color-secondary);
    font-size: 14px;
    margin-bottom: 20px;
}

</style>